using UnityEngine;
using UnityEngine.SceneManagement;

public class Fps : MonoBehaviour
{
	private float deltaTime;

	private Rect rect;

	private GUIStyle style;

	private Color greenColor;

	private Color yellowColor;

	private Color orangeColor;

	private Color redColor;

	private void Start()
	{
		style = new GUIStyle();
		int width = Screen.width;
		int height = Screen.height;
		rect = new Rect(0f, 0f, width, height * 2 / 100);
		style.alignment = TextAnchor.UpperLeft;
		style.fontSize = height * 6 / 100;
		greenColor = Color.green;
		yellowColor = new Color(0.949f, 1f, 0f);
		orangeColor = new Color(1f, 0.647f, 0f);
		redColor = Color.red;
	}

	private void Update()
	{
		deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
	}

	private void OnGUI()
	{
		float num = deltaTime * 1000f;
		float num2 = 1f / deltaTime;
		string text = $"{num:0.0} ms ({num2:0.} fps)";
		if (num2 >= 60f)
		{
			style.normal.textColor = greenColor;
		}
		else if (num2 >= 50f)
		{
			style.normal.textColor = yellowColor;
		}
		else if (num2 >= 30f)
		{
			style.normal.textColor = orangeColor;
		}
		else
		{
			style.normal.textColor = redColor;
		}
		GUI.Label(rect, text, style);
	}

	public void ResetScene()
	{
		SceneManager.LoadScene("SampleScene");
	}
}
